home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / xpcom / nsIStreamBufferAccess.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  11KB  |  263 lines

  1. /*
  2.  * DO NOT EDIT.  THIS FILE IS GENERATED FROM nsIStreamBufferAccess.idl
  3.  */
  4.  
  5. #ifndef __gen_nsIStreamBufferAccess_h__
  6. #define __gen_nsIStreamBufferAccess_h__
  7.  
  8.  
  9. #ifndef __gen_nsISupports_h__
  10. #include "nsISupports.h"
  11. #endif
  12.  
  13. #ifndef __gen_nsrootidl_h__
  14. #include "nsrootidl.h"
  15. #endif
  16.  
  17. /* For IDL files that don't want to include root IDL files. */
  18. #ifndef NS_NO_VTABLE
  19. #define NS_NO_VTABLE
  20. #endif
  21.  
  22. /* starting interface:    nsIStreamBufferAccess */
  23. #define NS_ISTREAMBUFFERACCESS_IID_STR "ac923b72-ac87-4892-ac7a-ca385d429435"
  24.  
  25. #define NS_ISTREAMBUFFERACCESS_IID \
  26.   {0xac923b72, 0xac87, 0x4892, \
  27.     { 0xac, 0x7a, 0xca, 0x38, 0x5d, 0x42, 0x94, 0x35 }}
  28.  
  29. /**
  30.  * An interface for access to a buffering stream implementation's underlying
  31.  * memory buffer.
  32.  *
  33.  * Stream implementations that QueryInterface to nsIStreamBufferAccess must
  34.  * ensure that all buffers are aligned on the most restrictive type size for
  35.  * the current architecture (e.g., sizeof(double) for RISCy CPUs).  malloc(3)
  36.  * satisfies this requirement.
  37.  */
  38. class NS_NO_VTABLE nsIStreamBufferAccess : public nsISupports {
  39.  public: 
  40.  
  41.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTREAMBUFFERACCESS_IID)
  42.  
  43.   /**
  44.      * Get access to a contiguous, aligned run of bytes in the stream's buffer.
  45.      * Exactly one successful getBuffer call must occur before a putBuffer call
  46.      * taking the non-null pointer returned by the successful getBuffer.
  47.      *
  48.      * The run of bytes are the next bytes (modulo alignment padding) to read
  49.      * for an input stream, and the next bytes (modulo alignment padding) to
  50.      * store before (eventually) writing buffered data to an output stream.
  51.      * There can be space beyond this run of bytes in the buffer for further
  52.      * accesses before the fill or flush point is reached.
  53.      *
  54.      * @param aLength
  55.      *    Count of contiguous bytes requested at the address A that satisfies
  56.      *    (A & aAlignMask) == 0 in the buffer, starting from the current stream
  57.      *    position, mapped to a buffer address B.  The stream implementation
  58.      *    must pad from B to A by skipping bytes (if input stream) or storing
  59.      *    zero bytes (if output stream).
  60.      *
  61.      * @param aAlignMask
  62.      *    Bit-mask computed by subtracting 1 from the power-of-two alignment
  63.      *    modulus (e.g., 3 or sizeof(PRUint32)-1 for PRUint32 alignment).
  64.      *
  65.      * @return
  66.      *    The aligned pointer to aLength bytes in the buffer, or null if the
  67.      *    buffer has no room for aLength bytes starting at the next address A
  68.      *    after the current position that satisfies (A & aAlignMask) == 0.
  69.      */
  70.   /* [notxpcom] charPtr getBuffer (in PRUint32 aLength, in PRUint32 aAlignMask); */
  71.   NS_IMETHOD_(char *) GetBuffer(PRUint32 aLength, PRUint32 aAlignMask) = 0;
  72.  
  73.   /**
  74.      * Relinquish access to the stream's buffer, filling if at end of an input
  75.      * buffer, flushing if completing an output buffer.  After a getBuffer call
  76.      * that returns non-null, putBuffer must be called.
  77.      *
  78.      * @param aBuffer
  79.      *    A non-null pointer returned by getBuffer on the same stream buffer
  80.      *    access object.
  81.      *
  82.      * @param aLength
  83.      *    The same count of contiguous bytes passed to the getBuffer call that
  84.      *    returned aBuffer.
  85.      */
  86.   /* [notxpcom] void putBuffer (in charPtr aBuffer, in PRUint32 aLength); */
  87.   NS_IMETHOD_(void) PutBuffer(char * aBuffer, PRUint32 aLength) = 0;
  88.  
  89.   /**
  90.      * Disable and enable buffering on the stream implementing this interface.
  91.      * DisableBuffering flushes an output stream's buffer, and invalidates an
  92.      * input stream's buffer.
  93.      */
  94.   /* void disableBuffering (); */
  95.   NS_IMETHOD DisableBuffering(void) = 0;
  96.  
  97.   /* void enableBuffering (); */
  98.   NS_IMETHOD EnableBuffering(void) = 0;
  99.  
  100.   /**
  101.      * The underlying, unbuffered input or output stream.
  102.      */
  103.   /* readonly attribute nsISupports unbufferedStream; */
  104.   NS_IMETHOD GetUnbufferedStream(nsISupports * *aUnbufferedStream) = 0;
  105.  
  106. };
  107.  
  108. /* Use this macro when declaring classes that implement this interface. */
  109. #define NS_DECL_NSISTREAMBUFFERACCESS \
  110.   NS_IMETHOD_(char *) GetBuffer(PRUint32 aLength, PRUint32 aAlignMask); \
  111.   NS_IMETHOD_(void) PutBuffer(char * aBuffer, PRUint32 aLength); \
  112.   NS_IMETHOD DisableBuffering(void); \
  113.   NS_IMETHOD EnableBuffering(void); \
  114.   NS_IMETHOD GetUnbufferedStream(nsISupports * *aUnbufferedStream); 
  115.  
  116. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  117. #define NS_FORWARD_NSISTREAMBUFFERACCESS(_to) \
  118.   NS_IMETHOD_(char *) GetBuffer(PRUint32 aLength, PRUint32 aAlignMask) { return _to GetBuffer(aLength, aAlignMask); } \
  119.   NS_IMETHOD_(void) PutBuffer(char * aBuffer, PRUint32 aLength) { return _to PutBuffer(aBuffer, aLength); } \
  120.   NS_IMETHOD DisableBuffering(void) { return _to DisableBuffering(); } \
  121.   NS_IMETHOD EnableBuffering(void) { return _to EnableBuffering(); } \
  122.   NS_IMETHOD GetUnbufferedStream(nsISupports * *aUnbufferedStream) { return _to GetUnbufferedStream(aUnbufferedStream); } 
  123.  
  124. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  125. #define NS_FORWARD_SAFE_NSISTREAMBUFFERACCESS(_to) \
  126.   NS_IMETHOD_(char *) GetBuffer(PRUint32 aLength, PRUint32 aAlignMask) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetBuffer(aLength, aAlignMask); } \
  127.   NS_IMETHOD_(void) PutBuffer(char * aBuffer, PRUint32 aLength) { return !_to ? NS_ERROR_NULL_POINTER : _to->PutBuffer(aBuffer, aLength); } \
  128.   NS_IMETHOD DisableBuffering(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->DisableBuffering(); } \
  129.   NS_IMETHOD EnableBuffering(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->EnableBuffering(); } \
  130.   NS_IMETHOD GetUnbufferedStream(nsISupports * *aUnbufferedStream) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUnbufferedStream(aUnbufferedStream); } 
  131.  
  132. #if 0
  133. /* Use the code below as a template for the implementation class for this interface. */
  134.  
  135. /* Header file */
  136. class nsStreamBufferAccess : public nsIStreamBufferAccess
  137. {
  138. public:
  139.   NS_DECL_ISUPPORTS
  140.   NS_DECL_NSISTREAMBUFFERACCESS
  141.  
  142.   nsStreamBufferAccess();
  143.  
  144. private:
  145.   ~nsStreamBufferAccess();
  146.  
  147. protected:
  148.   /* additional members */
  149. };
  150.  
  151. /* Implementation file */
  152. NS_IMPL_ISUPPORTS1(nsStreamBufferAccess, nsIStreamBufferAccess)
  153.  
  154. nsStreamBufferAccess::nsStreamBufferAccess()
  155. {
  156.   /* member initializers and constructor code */
  157. }
  158.  
  159. nsStreamBufferAccess::~nsStreamBufferAccess()
  160. {
  161.   /* destructor code */
  162. }
  163.  
  164. /* [notxpcom] charPtr getBuffer (in PRUint32 aLength, in PRUint32 aAlignMask); */
  165. NS_IMETHODIMP_(char *) nsStreamBufferAccess::GetBuffer(PRUint32 aLength, PRUint32 aAlignMask)
  166. {
  167.     return NS_ERROR_NOT_IMPLEMENTED;
  168. }
  169.  
  170. /* [notxpcom] void putBuffer (in charPtr aBuffer, in PRUint32 aLength); */
  171. NS_IMETHODIMP_(void) nsStreamBufferAccess::PutBuffer(char * aBuffer, PRUint32 aLength)
  172. {
  173.     return NS_ERROR_NOT_IMPLEMENTED;
  174. }
  175.  
  176. /* void disableBuffering (); */
  177. NS_IMETHODIMP nsStreamBufferAccess::DisableBuffering()
  178. {
  179.     return NS_ERROR_NOT_IMPLEMENTED;
  180. }
  181.  
  182. /* void enableBuffering (); */
  183. NS_IMETHODIMP nsStreamBufferAccess::EnableBuffering()
  184. {
  185.     return NS_ERROR_NOT_IMPLEMENTED;
  186. }
  187.  
  188. /* readonly attribute nsISupports unbufferedStream; */
  189. NS_IMETHODIMP nsStreamBufferAccess::GetUnbufferedStream(nsISupports * *aUnbufferedStream)
  190. {
  191.     return NS_ERROR_NOT_IMPLEMENTED;
  192. }
  193.  
  194. /* End of implementation class template. */
  195. #endif
  196.  
  197. // Swap macros, used to convert to/from canonical (big-endian) format
  198. #if defined IS_LITTLE_ENDIAN
  199. # define NS_SWAP16(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
  200. # define NS_SWAP32(x) ((NS_SWAP16((x) & 0xffff) << 16) | (NS_SWAP16((x) >> 16)))
  201. // We want to avoid casting to 32-bit types if possible, since that violates
  202. // aliasing rules (a standard compiler may assume that pointers of two types
  203. // do not address overlapping storage).
  204. //
  205. // XXX What if we have a compiler that follows aliasing rules strictly but
  206. // doesn't have a 64-bit int type?
  207. //
  208. // XXXbe shouldn't NSPR's LL_INIT work for non-constant arguments in all cases?
  209. # if defined HAVE_LONG_LONG
  210. #  if PR_BYTES_PER_LONG == 8
  211. #   define ULL_(x)     x ## UL
  212. #  elif (defined WIN32 || defined WIN16) && !defined __GNUC__
  213. #   define ULL_(x)     ((uint64) x ## i64)
  214. #  else
  215. #   define ULL_(x)     x ## ULL
  216. #  endif
  217. #  define NS_SWAP64(x) ((((x)    & ULL_(0xff00000000000000))    >> 56) |      \
  218.                         (((x)    & ULL_(0x00ff000000000000))    >> 40) |      \
  219.                         (((x)    & ULL_(0x0000ff0000000000))    >> 24) |      \
  220.                         (((x)    & ULL_(0x000000ff00000000))    >> 8)  |      \
  221.                         (((x)    & ULL_(0x00000000ff000000))    << 8)  |      \
  222.                         (((x)    & ULL_(0x0000000000ff0000))    << 24) |      \
  223.                         (((x)    & ULL_(0x000000000000ff00))    << 40) |      \
  224.                         (((x) /* & ULL_(0x00000000000000ff) */) << 56))
  225. # else
  226. #  define NS_SWAP64(x) LL_INIT((((x).lo /* & 0xff000000ul */) >> 24) |        \
  227.                                (((x).lo    & 0x00ff0000ul)    >> 8)  |        \
  228.                                (((x).lo    & 0x0000ff00ul)    << 8)  |        \
  229.                                (((x).lo /* & 0x000000fful */) << 24),         \
  230.                                (((x).hi /* & 0xff000000ul */) >> 24) |        \
  231.                                (((x).hi    & 0x00ff0000ul)    >> 8)  |        \
  232.                                (((x).hi    & 0x0000ff00ul)    << 8)  |        \
  233.                                (((x).hi /* & 0x000000fful */) << 24))
  234. # endif
  235. #elif defined IS_BIG_ENDIAN
  236. # define NS_SWAP16(x) (x)
  237. # define NS_SWAP32(x) (x)
  238. # define NS_SWAP64(x) (x)
  239. #else
  240. # error "Unknown byte order"
  241. #endif
  242. /**
  243.  * These macros get and put a buffer given either an sba parameter that may
  244.  * point to an object implementing nsIStreamBufferAccess, nsIObjectInputStream,
  245.  * or nsIObjectOutputStream.
  246.  */
  247. #define NS_GET_BUFFER(sba,n,a)  ((sba)->GetBuffer(n, a))
  248. #define NS_PUT_BUFFER(sba,p,n)  ((sba)->PutBuffer(p, n))
  249. #define NS_GET8(p)              (*(PRUint8*)(p))
  250. #define NS_GET16(p)             NS_SWAP16(*(PRUint16*)(p))
  251. #define NS_GET32(p)             NS_SWAP32(*(PRUint32*)(p))
  252. #define NS_GET64(p)             NS_SWAP64(*(PRUint64*)(p))
  253. #define NS_GET_FLOAT(p)         ((float)NS_SWAP32(*(PRUint32*)(p)))
  254. #define NS_GET_DOUBLE(p)        ((double)NS_SWAP64(*(PRUint64*)(p)))
  255. #define NS_PUT8(p,x)            (*(PRUint8*)(p) = (x))
  256. #define NS_PUT16(p,x)           (*(PRUint16*)(p) = NS_SWAP16(x))
  257. #define NS_PUT32(p,x)           (*(PRUint32*)(p) = NS_SWAP32(x))
  258. #define NS_PUT64(p,x)           (*(PRUint64*)(p) = NS_SWAP64(x))
  259. #define NS_PUT_FLOAT(p,x)       (*(PRUint32*)(p) = NS_SWAP32(*(PRUint32*)&(x)))
  260. #define NS_PUT_DOUBLE(p,x)      (*(PRUint64*)(p) = NS_SWAP64(*(PRUint64*)&(x)))
  261.  
  262. #endif /* __gen_nsIStreamBufferAccess_h__ */
  263.